package com.dpad.telematicsclientapp.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import com.dpad.telematicsclientapp.android.R;
import com.dpad.telematicsclientapp.mvp.kit.Kits;
import com.dpad.telematicsclientapp.netlibrary.MainApplicaton;
import com.dpad.telematicsclientapp.netlibrary.newapp.entity.HomeCarDataBean;

import java.util.List;


/**
 * ================================================
 * 作    者：booob
 * 版    本：1.0
 * 创建日期：2018-08-23-0023 10:56
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class TopPopuWindowAdapter extends BaseQuickAdapter<HomeCarDataBean.ResultBean.VehinfosBean, BaseViewHolder> {

    private List<HomeCarDataBean.ResultBean.VehinfosBean> data;

    public TopPopuWindowAdapter(@Nullable List<HomeCarDataBean.ResultBean.VehinfosBean> data) {
        super(R.layout.popuwindow_item, data);
        this.data = data;
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeCarDataBean.ResultBean.VehinfosBean item) {
        if (Kits.Empty.check(item.getPlateNumber())) {
            helper.setText(R.id.popu_car_num_tv, item.getVin());
        } else {
            helper.setText(R.id.popu_car_num_tv, item.getPlateNumber());
        }

        if (item.isChecked()) {
            helper.setTextColor(R.id.popu_car_num_tv, MainApplicaton.getContext().getResources().getColor(R.color.colorPrimary));
        } else {
            helper.setTextColor(R.id.popu_car_num_tv, MainApplicaton.getContext().getResources().getColor(R.color.white));
        }
        if (helper.getAdapterPosition() == data.size()-1){
            helper.setVisible(R.id.item_diver,false);
        }else {
            helper.setVisible(R.id.item_diver,true);
        }
    }
}
